<template>
  <div class="index">
    <el-container>
      <el-header>
        <el-breadcrumb>
          <el-breadcrumb-item>账号与权限</el-breadcrumb-item>
          <el-breadcrumb-item>账号列表</el-breadcrumb-item>
          <el-breadcrumb-item>新增账号</el-breadcrumb-item>
        </el-breadcrumb>
      </el-header>
      <el-main>
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="100px"
          size="mini"
          class="demo-ruleForm"
        >
          <el-form-item label="账号" prop="idName">
            <el-input v-model="ruleForm.idName"></el-input>
          </el-form-item>
          <el-form-item label="账号所属" prop="idOwner">
            <el-radio-group v-model="ruleForm.idOwner">
              <el-radio label="官方"></el-radio>
              <el-radio label="供应商"></el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="供应商" prop="supplier">
            <el-select v-model="ruleForm.supplier" placeholder="请选择">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="供应商地址" prop="supplierAddress">
            <el-input v-model="ruleForm.supplierAddress" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="供应商简介" prop="supplierDesc">
            <el-input type="textarea" v-model="ruleForm.supplierDesc" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="供应商邮箱" prop="supplierEmail">
            <el-input v-model="ruleForm.supplierEmail"></el-input>
          </el-form-item>
          <el-form-item label="备注" prop="remarks">
            <el-input type="textarea" v-model="ruleForm.remarks"></el-input>
          </el-form-item>
          <el-form-item label="账号状态" prop="idStatus">
            <el-radio-group v-model="ruleForm.idStatus">
              <el-radio label="启用"></el-radio>
              <el-radio label="禁用"></el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
          </el-form-item>
        </el-form>
      </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        idName: "",
        idOwner: "",
        supplier: "",
        supplierAddress: "",
        supplierDesc: "",
        supplierEmail: "",
        remarks: "",
        idStatus: ""
      },
      rules: {
        idName: [
          { required: true, message: "请输入账号", trigger: "blur" }
        ],
        idOwner: [
          { required: true, message: "请选择账号所属", trigger: "change" }
        ],
        supplier: [
          { required: true, message: "请选择账号所属", trigger: "change" }
        ],
        supplierEmail: [
          { required: true, message: "请输入供应商邮箱", trigger: "blur" }
        ],
        idStatus: [
          { required: true, message: "请选择账号状态", trigger: 'change' }
        ]
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
};
</script>

<style scoped>
.index .el-header {
  height: 60px;
  border-bottom: 1px solid #f3f3f3;
}
.el-breadcrumb {
  height: 60px;
  line-height: 60px;
}
</style>